﻿using System;
using System.Collections.Generic;
using Microsoft.ApplicationBlocks.Data;
    using System.Configuration;
    using System.IO;
    using System.Data;
    using System.Text.RegularExpressions;
using System.Data.SqlClient;

namespace ZSafeProjectNameZ.Tests
{
    public static class DatabaseEnvironment
    {
        #region Properties
        public static string ConnectionString
        {
            get
            {
                return string.Format(TestDatabaseConnectionFormatString, TargetDatabaseFolderPath, TestDatabaseName);
            }
        }

        public static string TestDatabaseConnectionFormatString
        {
            get { return ConfigurationManager.AppSettings["TestDatabaseConnectionFormatString"]; }
        }

        public static string TestDatabaseName
        {
            get { return ConfigurationManager.AppSettings["TestDatabaseName"]; }
        }

        private static string _TargetDatabaseFolderPath;
        public static string TargetDatabaseFolderPath
        {
            get
            {
                if (_TargetDatabaseFolderPath == null)
                {
                    string configValue = ConfigurationManager.AppSettings["TargetDatabaseFolderPath"];
                    _TargetDatabaseFolderPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), configValue));
                }
                return _TargetDatabaseFolderPath;
            }
        }

        private static string _SourceDatabaseFolderPath;
        public static string SourceDatabaseFolderPath
        {
            get
            {
                if (_SourceDatabaseFolderPath == null)
                {
                    string configValue = ConfigurationManager.AppSettings["SourceDatabaseFolderPath"];
                    _SourceDatabaseFolderPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), configValue));
                }
                return _SourceDatabaseFolderPath;
            }
        }

        public static string TestDatabaseSetupScript
        {
            get { return ConfigurationManager.AppSettings["TestDatabaseSetupScript"]; }
        }

        private static List<string> _ModuleInstallScripts = null;
        public static List<string> ModuleInstallScripts
        {
            get
            {
                if (_ModuleInstallScripts == null)
                {
                    string configValue = ConfigurationManager.AppSettings["ModuleInstallScripts"];
                    _ModuleInstallScripts = new List<string>(configValue.Split(';'));

                }
                return _ModuleInstallScripts;
            }
        }

        public static string ModuleUnInstallScript
        {
            get { return ConfigurationManager.AppSettings["ModuleUnInstallScripts"]; }
        }

        public static string ObjectQualifier
        {
            get
            {
                return ConfigurationManager.AppSettings["ObjectQualifier"];
            }
        }

        public static string DatabaseOwner
        {
            get
            {
                return ConfigurationManager.AppSettings["DatabaseOwner"];
            }
        }
        #endregion

    }
}
